// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@DATAVIEW}}-data-view/\{{spinalCase ctrl.codeName}}-data-view-model.ts.hbs生成
import { IDataViewCtrlModel } from "@/core";

//  获取列表模型
function getModel(): IDataViewCtrlModel {
    return {
        cssName: "{{#if ctrl.psSysCss}}{{ctrl.psSysCss.cssName}}{{/if}}",             
        aggMode: '{{ctrl.aggMode}}',
        caption: '{{ctrl.caption}}',
        controlType: '{{ctrl.controlType}}',
        codeName: '{{ctrl.codeName}}',
        entityCodeName: '{{ctrl.psAppDataEntity.codeName}}',
        entityLogicName: '{{ctrl.psAppDataEntity.logicName}}',
{{#if ctrl.emptyText}}
        emptyText: "{{ctrl.emptyText}}",
{{/if}}
{{#if ctrl.emptyTextPSLanguageRes}}
        emptyTextPSLanguageRes: "{{ctrl.emptyTextPSLanguageRes}}",
{{/if}}        
{{#and ctrl.enableGroup (neq ctrl.groupMode 'NONE')}}
        enableGroup: true,
        //  请确保此项与表格分组列模型中的dataIndex一致
        groupDataIndex: 'grid_group',
        groupMode: '{{ctrl.groupMode}}',
        groupField: '{{lowerCase ctrl.groupPSAppDEField.codeName}}',
  {{#eq ctrl.groupMode 'CODELIST'}}
        groupCodeListTag: '{{ctrl.groupPSCodeList.codeListTag}}',
  {{/eq}}
{{/and}}
        name: '{{ctrl.name}}',
        noSort: {{ctrl.noSort}},
        showHeader: {{#if ctrl.hideHeader}}false{{else}}true{{/if}},
        sortDir: '{{ctrl.minorSortDir}}',
        sortField: '{{#if ctrl.minorSortPSAppDEField}}{{lowerCase ctrl.minorSortPSAppDEField.codeName}}{{/if}}',
        singleSelect:{{#if ctrl.isSingleSelect}}true{{else}}false{{/if}},
{{#if ctrl.psDEDataImport}}
        dataImport: {
            codeName: '{{ctrl.psDEDataImport.codeName}}',
            ignoreError: {{ctrl.psDEDataImport.ignoreError}},
        },
{{/if}}
        paging: {
            defaultPageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}}
        },
{{#if ctrl.psDEDataViewItems}}
    {{#each ctrl.psDEDataViewItems as | dataViewItem |}}
        {{#if (and (eq dataViewItem.itemType 'ACTIONITEM') dataViewItem.psDEUIActionGroup)}}
        uIActionGroup: {
            {{#each dataViewItem.psDEUIActionGroup.psUIActionGroupDetails as | uiAction |}}
            "{{uiAction.psUIAction.uIActionTag}}": {
                caption: "{{uiAction.psUIAction.caption}}",
                uIActionMode: "{{uiAction.psUIAction.uIActionMode}}",
                disabled: false,
                visible: true,
                actionTag: "{{uiAction.psUIAction.uIActionTag}}",
                noPrivDisplayMode: {{uiAction.psUIAction.noPrivDisplayMode}},
                dataAccessAction: "{{uiAction.psUIAction.dataAccessAction}}",
                actionTarget: "{{uiAction.psUIAction.actionTarget}}",
                showCaption: {{uiAction.showCaption}},
                showIcon: {{uiAction.showIcon}},
                predefinedType: "{{uiAction.psUIAction.predefinedType}}",
                actionDECodeName: "{{#if uiAction.psUIAction.psAppDataEntity}}{{uiAction.psUIAction.psAppDataEntity.codeName}}{{/if}}",
                {{#if uiAction.psUIAction.psSysImage}}{{#if uiAction.psUIAction.psSysImage.imagePath}}imgPath: "{{uiAction.psUIAction.psSysImage.imagePath}}",{{/if}}
                {{#if uiAction.psUIAction.psSysImage.cssClass}}iconClass: "{{uiAction.psUIAction.psSysImage.cssClass}}"{{/if}}{{/if}}
            }{{#unless @last}},{{/unless}}
            {{/each}}
        }
        {{/if}}
    {{/each}}
{{/if}}
    };
}

export const model = getModel();